package com.example.demo.mapper;

import com.example.demo.entity.ChatMessage;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ChatMessageMapper {

    @Insert("INSERT INTO chat_messages (`chatId`, `from`, `name`, `to`, `content`) VALUES (#{chatId}, #{from}, #{name}, #{to}, #{content})")
    void insert(ChatMessage message);


    @Select("SELECT * FROM chat_messages WHERE `chatId` = #{chatId} ")
    List<ChatMessage> selectByChatId(String chatId);
}